<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>用户登录</title>
  <style>
    body { font-family: Arial, sans-serif; max-width: 500px; margin: 0 auto; padding: 20px; }
    .form-group { margin-bottom: 15px; }
    label { display: block; margin-bottom: 5px; font-weight: bold; }
    input { width: 100%; padding: 8px; box-sizing: border-box; }
    button { background-color: #4CAF50; color: white; padding: 10px 15px; border: none; cursor: pointer; }
    .error { color: red; margin: 10px 0; }
  </style>
</head>
<body>
<h1>用户登录</h1>
<!-- 表单action指向登录Servlet -->
<form action="${pageContext.request.contextPath}/login" method="post">
  <div class="form-group">
    <label for="username">用户名：</label>
    <input type="text" id="username" name="username" required>
  </div>
  <div class="form-group">
    <label for="password">密码：</label>
    <input type="password" id="password" name="password" required>
  </div>
  <!-- 显示登录错误信息 -->
  <div class="error">
    <%= request.getAttribute("error") != null ? request.getAttribute("error") : "" %>
  </div>
  <button type="submit">登录</button>
</form>
<p>还没有账号？<a href="${pageContext.request.contextPath}/user-register/register.jsp">去注册</a></p>
</body>
</html>